package cn.oa.dao;

import cn.oa.entity.Employee;
import cn.oa.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

import java.sql.SQLException;
import java.util.Date;

public class EmployeeText {
    SqlSessionFactory sqlSessionFactory = MybatisUtil.sessionFactory;
    SqlSession sqlSession = sqlSessionFactory.openSession();
    @Test
    public void findEmployee() throws SQLException {
        EmployeeDao employeeDao=sqlSession.getMapper(EmployeeDao.class);
        Employee employee = employeeDao.findEmployee("1000890902","123456");
        System.out.println(employee);
        sqlSession.close();
    }
    @Test
    public void add() throws SQLException {
        EmployeeDao employeeDao=sqlSession.getMapper(EmployeeDao.class);
        Employee employee=new Employee();

        employee.setEmployeeNo("4886448");
        employee.setPassword("123456");
        employee.setName("鳄梨");
        employee.setEntryTime(new Date());
        employee.setPhoto("5864448489");
        employee.setDeptId(4);
        employee.setPositionId(5);
        int ret  = employeeDao.addNewEmployee(employee);
        System.out.println(ret>0?"成功":"wu");
        sqlSession.commit();
        sqlSession.close();
    }
}
